home *** CD-ROM | disk | FTP | other *** search
/ Champak 50 / Volume 50 - JOGO DISK .iso / Games / moonstonemadness.swf / scripts / __Packages / MoonStoneObstacle.as < prev    next >
Text File  |  2007-09-27  |  2KB  |  56 lines

  1. class MoonStoneObstacle extends SideScroller.StaticObject
  2. {
  3.    function MoonStoneObstacle(__mcRef, __oLayer, _nPercent)
  4.    {
  5.       super(__mcRef,__oLayer);
  6.       if(_nPercent == undefined)
  7.       {
  8.          _nPercent = 100;
  9.       }
  10.       this.nPercent = _nPercent;
  11.       this.bObjectBlock = false;
  12.       this.bObjectSpecial = true;
  13.       this.setState("Idle");
  14.    }
  15.    function onHitSpecial(__oRef)
  16.    {
  17.       if(this.__get__CurrentState() == "Idle")
  18.       {
  19.          if(TakGround(__oRef).__get__IsInHeadSwing())
  20.          {
  21.             this.__get__ParentLayer().doAddListener(this);
  22.             Library.Sound.SoundManager.doPlaySoundInCat(Main.SOUND_CAT_SOUND,"ItemHit.mp3");
  23.             if(Library.Utils.MoreMath.getRandomRange(1,100) < this.nPercent)
  24.             {
  25.                var _loc3_ = this.__get__ParentLayer().doAttachVisual("Dynamic_MoonStone");
  26.                _loc3_._x = this.__get__Coord().x;
  27.                _loc3_._y = this.__get__Coord().y;
  28.                _global.LevelManager.Instance.doAddMoonStone(_loc3_);
  29.             }
  30.             this.setState("Explode");
  31.             this.doLockState();
  32.          }
  33.       }
  34.    }
  35.    function doDestroy()
  36.    {
  37.       this.__get__ParentLayer().doRemoveListener(this);
  38.       super.doDestroy();
  39.    }
  40.    function doExplode()
  41.    {
  42.       if(this.isStateComplete())
  43.       {
  44.          if(!this.mcRef.bStateAfterExplosion)
  45.          {
  46.             this.doDestroy();
  47.          }
  48.          else
  49.          {
  50.             this.doForcedSetState("ExplodedIdle");
  51.             this.__get__ParentLayer().doRemoveListener(this);
  52.          }
  53.       }
  54.    }
  55. }
  56.